// import cloneDeep from 'lodash.clonedeep'
/**
 * 从树里面查找数据
 * @param {要查找的值} value 
 * @param {查找完后回调赋值} callback 
 * @param {数据源} treeList 
 */
export const getTree = (value, callback, treeList) => {
    let result = []
    function changeFieldCode(data, result) {
        data.filter((item) => {
            if (item.children.length !== 0) {
                if (item.title.toLowerCase().indexOf(value.toLowerCase()) >= 0) {
                    // let val = cloneDeep(item)
                    result.push(item)
                }
                changeFieldCode(item.children, result)
            } else {
                if (item.title.toLowerCase().indexOf(value.toLowerCase()) >= 0) {
                    result.push(item)
                }
            }
        })
        callback(result)
    }
    let cache = treeList
    changeFieldCode(cache, result)
}

